package com.nomi.blog.utils;

import lombok.Data;

import java.io.Serializable;


@Data
public class Result<T> implements Serializable {
    //序列化版本号
    private static final long serialVersionUID = 1L;

    private int code;

    private String message;
    private T data ;

    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return new Result<>(200, "success", null);
    }

    public static <T> Result<T> success(String message) {
        return new Result<>(200, message, null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(200, "success", data);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>(200, message, data);
    }

    public static <T> Result<T> fail() {
        return new Result<>(500, "fail", null);
    }

    public static <T> Result<T> fail(String message) {
        return new Result<>(500, message, null);
    }

    public static <T> Result<T> fail(int code,String message){
        return new Result<>(code,message,null);
    }


}
